package com.tengju.bff.interfaces.covercharge.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author liang_shi
 * @date 2020/8/31 23:34
 * @description 操作类型
 */
@Getter
@AllArgsConstructor
public enum OperateTypeEnum {

    /**
     * 结算
     */
    SETTLE(1, "结算"),

    REFUND(2, "退款"),
    ;


    private Integer type;


    private String msg;


    /**
     * 根据类型获取指定枚举
     *
     * @param type 类型
     * @return 结果
     */
    public static OperateTypeEnum getInstance(Integer type) {
        if (Objects.isNull(type)) {
            return null;
        }
        for (OperateTypeEnum typeEnum : OperateTypeEnum.values()) {
            if (typeEnum.getType().equals(type)) {
                return typeEnum;
            }
        }
        return null;
    }

}
